function payTypeChange(){
		$("#creditcard-card-type").val($("#paytype").val());
		$("#creditcard-number").val($("#payCcNo").val());
		$("#insert-creditcard-popup").css("display","block");
		$("#insert-creditcard-popup").css("background-color","#FFF");
		$("#insert-creditcard-popup").css("z-index","2000000");
		$("#insert-creditcard-popup").css("position","absolute");
		$("#insert-creditcard-popup").draggable();
}

function btnCloseAddCreditPopup(){
	$("#creditcard-sharer").val("0");
	$("#creditcard-nameoncard").val("");
	$("#creditcard-number").val("");
	$("#creditcard-card-type").val("0");
	$("#creditcard-expire-month").val("");
	$("#creditcard-expire-year").val("");
	$("#creditcard-cvc").val("");
	$("#creditcard-bill-address").val("");
	$("#creditcard-bill-state").val("");
	$("#creditcard-bill-country").val("");
	$("#creditcard-bill-city").val("");
	$("#creditcard-bill-zipcode").val("");
	$("#insert-creditcard-popup").css("display","none");
}

function btnAddCredit(){
	if($("#creditcard-nameoncard").val().trim().length == 0){
		simpleDialog("please input name on card",100,null);
		return false;
	}else if($("#creditcard-number").val().trim().length == 0){
		simpleDialog("please input card number",100,null);
		return false;
	}else if($("#creditcard-expire-month").val().trim().length == 0){
		simpleDialog("please input date expire",100,null);
		return false;
	}else if($("#creditcard-expire-year").val().trim().length == 0){
		simpleDialog("please input date expire",100,null);
		return false;
	}else if($("#creditcard-card-type").val() == "0"){
		simpleDialog("please input card type",100,null);
		return false;
	}
	var sharer = $("#creditcard-sharer").val();
	var nameoncard = $("#creditcard-nameoncard").val();
	var cardnumber = $("#creditcard-number").val();
	var type = $("#creditcard-card-type").val();
	var expire = $("#creditcard-expire-month").val() + "/" + $("#creditcard-expire-year").val();
	var cvc = $("#creditcard-cvc").val();
	var address = $("#creditcard-bill-address").val();
	var state = $("#creditcard-bill-state").val();
	var country = $("#creditcard-bill-country").val();
	var city = $("#creditcard-bill-city").val();
	var zipcode = $("#creditcard-bill-zipcode").val();
	var link = "/CreditCardService?func=addFullCreditCard&sharer="+sharer+"&nameoncard="+nameoncard+"&cardnumber="+cardnumber
	+"&cardtype="+type+"&expiredate="+expire+"&cvc="+cvc+"&address="+address+"&state="+state+"&country="+country+"&city="+city+"&zipcode="+zipcode;
	simpleserviceWithArgs(link,null,AddCreditsuccess,null);	

	$("#creditcard-sharer").val("0");
	$("#creditcard-nameoncard").val("");
	$("#creditcard-number").val("");
	$("#creditcard-card-type").val("0");
	$("#creditcard-expire-month").val("");
	$("#creditcard-expire-year").val("");
	$("#creditcard-cvc").val("");
	$("#creditcard-bill-address").val("");
	$("#creditcard-bill-state").val("");
	$("#creditcard-bill-country").val("");
	$("#creditcard-bill-city").val("");
	$("#creditcard-bill-zipcode").val("");
	$("#insert-creditcard-popup").css("display","none");
}

function AddCreditsuccess(data,obj){
	var objArray = JSON.parse(data);
	if(objArray == null)
		simpleDialog(saveFail_label,100,null);
	else
		$("#payCcNo").val(objArray["CardNumber"]);
		$("#paytype").val(objArray["CardType"]);
}